home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / music / dsik_pas.zip / EXAM4.PAS < prev    next >
Pascal/Delphi Source File  |  1994-07-28  |  2KB  |  86 lines

  1. (*  exam4.pas - Digital Sound Interface Kit V1.01a example code
  2.  
  3.     Copyright 1993,94 Carlos Hasan
  4. *)
  5.  
  6. program Example;
  7. uses Crt,Sound,Load,TS;
  8.  
  9.  
  10. var
  11.   Card   : DSMCard;
  12.   Module : PDSM;
  13.   Sample : PDSMInst;
  14.   Volume : Integer;
  15.   TmrCnt : Word;
  16.   Secs   : Word;
  17.  
  18. procedure MyTimer; far;
  19. begin
  20.   inc(TmrCnt);
  21.   DSMPoll;
  22. end;
  23.  
  24. begin
  25.   if DSMLoadSetup(Card) then begin
  26.     writeln('Please run SETUP.EXE to configure.');
  27.     exit;
  28.   end;
  29.   if DSMInit(Card) then begin
  30.     writeln('Error Initializing the Sound System.');
  31.     exit;
  32.   end;
  33.   Module := DSMLoad('64MANIA.DSM',0);
  34.   Sample := DSMLoadSample('DING.WAV',0);
  35.   if (Module = nil) or (Sample = nil) then begin
  36.     case DSMStatus of
  37.       ERR_NORAM:  writeln('Not enough system memory.');
  38.       ERR_NODRAM: writeln('Not enough card memory.');
  39.       ERR_NOFILE: writeln('File not found.');
  40.       ERR_FORMAT: writeln('Invalid file format.');
  41.       ERR_ACCESS: writeln('File damaged.');
  42.     end;
  43.     DSMDone;
  44.     exit;
  45.   end;
  46.   writeln('Playing music.');
  47.  
  48.   { Play music using channels 0,1,2 and sound effect in channel 3 }
  49.   DSMSetupVoices(4,Module^.Song.MasterVolume);
  50.   DSMPlayMusic(Module);
  51.  
  52.   TSInit;
  53.   TSSetRate(100);
  54.   TSSetRoutine(MyTimer);
  55.  
  56.   for Volume := 0 to 64 do begin
  57.     DSMSetMusicVolume(Volume);
  58.     Delay(5);
  59.   end;
  60.  
  61.   Secs := 0;
  62.   while not keypressed do begin
  63.     { Play sample every second }
  64.     if TmrCnt >= 100 then begin
  65.       DSMPlaySample(3,Sample);
  66.       dec(TmrCnt,100);
  67.       inc(Secs);
  68.       Write('Timer: ',(Secs div 60):2,':',(Secs mod 60):2,#13);
  69.     end;
  70.   end;
  71.  
  72.   for Volume := 64 downto 0 do begin
  73.     DSMSetMusicVolume(Volume);
  74.     Delay(5);
  75.   end;
  76.  
  77.   DSMStopMusic;
  78.   DSMFreeSample(Sample);
  79.   DSMFree(Module);
  80.  
  81.   TSDone;
  82.   TSRestoreTime;
  83.  
  84.   DSMDone;
  85. end.
  86.